layui.use(['table','form','jquery', 'backend'],function () {
    var table = layui.table;
    var form = layui.form;
    var $ = layui.jquery;
    var backend = layui.backend;

    var cols = [
        [
            {type:'checkbox'},
            {title: '管理员', field: 'admin_id', align:'center', width:100},
            {title: '用户', field: 'user_id', align:'center'},
            {title: '路径', field: 'url', align:'center'},
            {title: '文件名', field: 'filename', align:'center'},
            {title: '文件大小', field: 'filesize', align:'center'},
            {title: '类型', field: 'mimetype', align:'center'},
            {title: '位置', field: 'storage', align:'center'},
            {title: '文件 sha1编码', field: 'sha1', align:'center'},
            {title: '操作', toolbar: '#bar', align:'center', width:195}
        ]
    ];

    var tableins = backend.table.curd({
        id: "table",
        elem: '#table',
        url: '/admin/attachment/index',
        cols: cols ,
        skin: 'line',
        toolbar: '#toolbar',
    });

    form.on('submit(query)', function(data){
        table.reload('table', {where:data.field})
        return false;
    });

    refresh = function(){
        table.reload('table');
    }
})
